package design.observer.eventbus;

/**
 * @author chengzhang
 * 2021/9/30 15:17
 */
public class TestEventBus {







    public static void main(String[] args) throws InterruptedException {

        DataObserver01 observer1 = new DataObserver01();
        DataObserver02 observer2 = new DataObserver02();

        EventBusCenter.register(observer1);
        EventBusCenter.register(observer2);

        System.out.println("============   start  ====================");

        // 只有注册的参数类型为String的方法会被调用
        EventBusCenter.post("post string method");
        EventBusCenter.post(123);

        System.out.println("============ after unregister ============");
        // 注销observer2
        EventBusCenter.unregister(observer2);
        EventBusCenter.post("post string method");
        EventBusCenter.post(123);

        System.out.println("============    end           =============");
    }







}
